<template>
  <div class="icons">
    <div class="icons-wraper">
      <swiper :options="swiperOption">
        <swiper-slide v-for="(item,index) in pages" :key="index">
          <div class="icons-item" v-for="item1 in item" :key="item1.id">
            <div class="icons-img">
              <img :src="item1.imgUrl" />
            </div>
            <p class="icons-desc">{{item1.desc}}</p>
          </div>
        </swiper-slide>
      </swiper>
    </div>
  </div>
</template>
<script >
export default {
  props: {
    iconsList: {
      type: Array
    }
  },
  data () {
    return {
      swiperOption: {}
    }
  },
  created () {
  //  console.log(this.iconsList)
  },
  computed: {
    pages () {
      const pages = []
      this.iconsList.forEach((ele, index) => {
        const page = Math.floor(index / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(ele)
      })
      return pages
    }
  }
}
</script>
<style lang="stylus" scoped>
@import '../../../assets/styles/varibles.styl';
@import '../../../assets/styles/mixins.styl';
.icons >>> .swiper-container
  width: 100%;
  overflow: hidden;
  height: 0;
  padding-bottom: 50%;
.icons >>> swiper-slide
  touch-action: none;
.icons {
  padding-top 0.1rem
  .icons-wraper {
    .icons-item {
      float: left;
      position: relative;
      overflow: hidden;
      width: 25%;
      height: 0;
      padding-bottom: 25%;

      // background red
      .icons-img {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0.44rem;
        // background blue
        box-sizing: border-box;
        padding: 0.1rem;

        img {
          display: block;
          margin: 0 auto;
          height: 100%;
        }
      }

      .icons-desc {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: 0.44rem;
        line-height: 0.44rem;
        text-align: center;
        color: $darkTextColor;
        ellipsis()
      }
    }
  }
}
</style>
